package com.zhiwei.codesecurity.common.utils;

import java.util.ArrayList;
import java.util.Set;

public class StringUtils {
    public static boolean isBlank(String str) {
        return !isNotBlank(str);
    }

    public static boolean isNotBlank(String str) {
        return str != null && !"".equals(str.trim());
    }

    public static String upperCaseFirstChar(String str) {
        return str.substring(0, 1).toUpperCase() + str.substring(1);
    }

    public static String lowerCaseFirstChar(String str) {
        return str.substring(0, 1).toLowerCase() + str.substring(1);
    }

    /**
     * 字符串是否为数字
     */
    public static boolean isNumeric(String str) {
        for (int i = str.length(); --i >= 0;) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

    /**
     * 数组拼字符串
     *
     */
    public static String arr2string(String[] param,String split) {
        String content = "";
        if(null!=param&&param.length>0){
            for (int i=0; i<param.length; i++) {
                content = content + param[i] +split;
            }
            content = content.substring(0,content.length()-1);
        }
        return content;
    }

    /**
     * ArrayList拼字符串
     *
     */
    public static String arr2string(ArrayList<String> param, String split) {
        String content = "";
        if(null!=param && param.size()>0){
            for (int i=0; i<param.size(); i++) {
                content = content + param.get(i) +split;
            }
            content = content.substring(0,content.length()-1);
        }
        return content;
    }

    /**
     * Set拼字符串
     *
     */
    public static String arr2string(Set<String> param, String split) {
        String content = "";
        if(null!=param && param.size()>0){
            for (String item : param) {
                content = content + item +split;
            }
            content = content.substring(0,content.length()-1);
        }
        return content;
    }


}
